package com.atguigu.eduucenter.api;


import com.aiguigu.commonutils.R;
import com.atguigu.eduucenter.entity.UcenterMember;
import com.atguigu.eduucenter.service.UcenterMemberService;
import com.atguigu.servicebase.entity.vo.UcenterMemberVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author Y丶HS练习谷粒商城
 * @since 2022-10-06
 */
@Api(description = "用户中心")
@RestController
@RequestMapping("/eduucenter/api/ucenterMember")
public class ApiUcenterMemberController {

    @Resource
    private UcenterMemberService ucenterMemberService;

    @ApiOperation("根id获取用户信息")
    @GetMapping("/getUserInfo/{id}")
    public UcenterMemberVo getUserInfo(@PathVariable("id") String id){
        UcenterMember ucenterMember = ucenterMemberService.getById(id);
        UcenterMemberVo ucenterMemberVo = new UcenterMemberVo();
        BeanUtils.copyProperties(ucenterMember,ucenterMemberVo);
        return ucenterMemberVo;
    }

    /**
     * 查询某一天的注册人数
     */
    @GetMapping("/countRegister/{day}")
    public R countRegister(@PathVariable("day") String day){
        Integer count =ucenterMemberService .countRegister(day);

        return R.ok().data(count);
    }

}

